<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>心灵守护 - 我的心理健康助手</title>
  <!-- 引入Tailwind CSS -->
  <script src="https://cdn.tailwindcss.com"></script>
  <!-- 引入Font Awesome -->
  <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
  <!-- 引入Chart.js -->
  <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.8/dist/chart.umd.min.js"></script>
  
  <!-- 配置Tailwind -->
  <script>
    tailwind.config = {
      theme: {
        extend: {
          colors: {
            primary: '#3B82F6',
            secondary: '#10B981',
            warning: '#F59E0B',
            danger: '#EF4444',
            info: '#6366F1',
            neutral: {
              100: '#F3F4F6',
              200: '#E5E7EB',
              300: '#D1D5DB',
              400: '#9CA3AF',
              500: '#6B7280',
              600: '#4B5563',
              700: '#374151',
              800: '#1F2937',
              900: '#111827',
            }
          },
          fontFamily: {
            sans: ['Inter', 'system-ui', 'sans-serif'],
          },
        },
      }
    }
  </script>
  
  <!-- 自定义工具类 -->
  <style type="text/tailwindcss">
    @layer utilities {
      .content-auto {
        content-visibility: auto;
      }
      .btn {
        @apply px-4 py-3 rounded-lg font-medium transition-all duration-200 flex items-center justify-center gap-2;
      }
      .btn-primary {
        @apply bg-primary text-white hover:bg-primary/90 active:bg-primary/80;
      }
      .btn-secondary {
        @apply bg-secondary text-white hover:bg-secondary/90 active:bg-secondary/80;
      }
      .btn-warning {
        @apply bg-warning text-white hover:bg-warning/90 active:bg-warning/80;
      }
      .btn-danger {
        @apply bg-danger text-white hover:bg-danger/90 active:bg-danger/80;
      }
      .card {
        @apply bg-white rounded-xl shadow-sm border border-neutral-200 overflow-hidden transition-all duration-300;
      }
      .nav-item {
        @apply flex flex-col items-center justify-center py-3 text-neutral-500 hover:text-primary transition-colors;
      }
      .nav-item.active {
        @apply text-primary;
      }
    }
  </style>
</head>

<body class="bg-neutral-100 font-sans text-neutral-800 min-h-screen flex flex-col">
  <!-- 顶部导航 -->
  <header class="bg-white border-b border-neutral-200 sticky top-0 z-20">
    <div class="container mx-auto px-4 h-16 flex items-center justify-between">
      <h1 class="text-xl font-bold text-neutral-800">心灵守护</h1>
      <div class="flex items-center gap-4">
        <button class="p-2 rounded-full hover:bg-neutral-100 relative">
          <i class="fa fa-bell-o text-neutral-600"></i>
          <span class="absolute top-1 right-1 w-2 h-2 bg-primary rounded-full"></span>
        </button>
        <img src="https://picsum.photos/id/237/200/200" alt="用户头像" class="w-8 h-8 rounded-full object-cover border border-neutral-200">
      </div>
    </div>
  </header>

  <!-- 主内容区 -->
  <main class="flex-1 overflow-y-auto">
    <!-- 欢迎区域 -->
    <section class="bg-gradient-to-r from-primary to-info text-white p-6">
      <div class="container mx-auto">
        <h2 class="text-[clamp(1.25rem,5vw,1.75rem)] font-bold">早上好，李小明</h2>
        <p class="mt-1 opacity-90">今天感觉怎么样？来记录一下你的心情吧</p>
        <button class="mt-4 btn btn-primary bg-white text-primary hover:bg-neutral-100 shadow-md">
          <i class="fa fa-microphone"></i>
          <span>记录今日心情</span>
        </button>
      </div>
    </section>
    
    <!-- 心理健康状态卡片 -->
    <section class="container mx-auto px-4 -mt-6 relative z-10">
      <div class="card p-5">
        <div class="flex items-center justify-between mb-4">
          <h3 class="font-semibold text-lg">当前心理健康状态</h3>
          <span class="text-sm text-neutral-500">更新于 今天 09:42</span>
        </div>
        
        <div class="flex items-center justify-center my-6">
          <div class="relative w-40 h-40">
            <!-- 状态圆环 -->
            <svg class="w-full h-full" viewBox="0 0 100 100">
              <circle cx="50" cy="50" r="45" fill="none" stroke="#E5E7EB" stroke-width="8"/>
              <circle cx="50" cy="50" r="45" fill="none" stroke="#EF4444" stroke-width="8" 
                      stroke-dasharray="283" stroke-dashoffset="70" transform="rotate(-90 50 50)"/>
            </svg>
            <!-- 状态文字 -->
            <div class="absolute inset-0 flex flex-col items-center justify-center">
              <span class="text-3xl font-bold text-danger">75</span>
              <span class="text-sm text-neutral-500">风险指数</span>
            </div>
          </div>
        </div>
        
        <!-- 状态标签 -->
        <div class="flex flex-wrap gap-2 justify-center mb-3">
          <span class="px-3 py-1 bg-danger/10 text-danger text-sm rounded-full">中度焦虑</span>
          <span class="px-3 py-1 bg-warning/10 text-warning text-sm rounded-full">轻度抑郁倾向</span>
        </div>
        
        <p class="text-center text-sm text-neutral-600">
          根据你的语音分析，建议进行15分钟的放松训练
        </p>
      </div>
    </section>
    
    <!-- 功能区域 -->
    <section class="container mx-auto px-4 py-6">
      <div class="grid grid-cols-2 gap-4 mb-8">
        <!-- 语音记录 -->
        <div class="card p-5 flex flex-col items-center justify-center gap-3 hover:shadow-md cursor-pointer">
          <div class="w-14 h-14 rounded-full bg-primary/10 flex items-center justify-center text-primary">
            <i class="fa fa-microphone text-xl"></i>
          </div>
          <h4 class="font-medium text-center">语音记录</h4>
          <p class="text-xs text-neutral-500 text-center">记录并分析你的心情</p>
        </div>
        
        <!-- 情感趋势 -->
        <div class="card p-5 flex flex-col items-center justify-center gap-3 hover:shadow-md cursor-pointer">
          <div class="w-14 h-14 rounded-full bg-info/10 flex items-center justify-center text-info">
            <i class="fa fa-line-chart text-xl"></i>
          </div>
          <h4 class="font-medium text-center">情感趋势</h4>
          <p class="text-xs text-neutral-500 text-center">查看情绪变化曲线</p>
        </div>
        
        <!-- 疏导方案 -->
        <div class="card p-5 flex flex-col items-center justify-center gap-3 hover:shadow-md cursor-pointer">
          <div class="w-14 h-14 rounded-full bg-secondary/10 flex items-center justify-center text-secondary">
            <i class="fa fa-heart-o text-xl"></i>
          </div>
          <h4 class="font-medium text-center">疏导方案</h4>
          <p class="text-xs text-neutral-500 text-center">个性化放松建议</p>
        </div>
        
        <!-- 专业咨询 -->
        <div class="card p-5 flex flex-col items-center justify-center gap-3 hover:shadow-md cursor-pointer">
          <div class="w-14 h-14 rounded-full bg-warning/10 flex items-center justify-center text-warning">
            <i class="fa fa-user-md text-xl"></i>
          </div>
          <h4 class="font-medium text-center">专业咨询</h4>
          <p class="text-xs text-neutral-500 text-center">联系心理咨询师</p>
        </div>
      </div>
      
      <!-- 今日疏导方案 -->
      <div class="card mb-8">
        <div class="p-5 border-b border-neutral-200">
          <h3 class="font-semibold text-lg">今日推荐疏导方案</h3>
        </div>
        <div class="p-5">
          <div class="flex items-start gap-4">
            <div class="w-16 h-16 rounded-lg bg-primary/10 flex items-center justify-center text-primary flex-shrink-0">
              <i class="fa fa-headphones text-2xl"></i>
            </div>
            <div class="flex-1">
              <h4 class="font-medium">呼吸放松训练</h4>
              <p class="text-sm text-neutral-500 mt-1">15分钟 · 缓解焦虑</p>
              <p class="text-sm text-neutral-600 mt-2">通过引导式呼吸，帮助你缓解当前的焦虑情绪，放松身心</p>
              
              <div class="flex items-center gap-3 mt-4">
                <button class="btn btn-primary flex-1">
                  <i class="fa fa-play"></i>
                  <span>开始训练</span>
                </button>
                <button class="w-10 h-10 rounded-lg border border-neutral-300 flex items-center justify-center text-neutral-600">
                  <i class="fa fa-bookmark-o"></i>
                </button>
              </div>
            </div>
          </div>
        </div>
      </div>
      
      <!-- 情感趋势图表 -->
      <div class="card mb-8">
        <div class="p-5 border-b border-neutral-200">
          <div class="flex items-center justify-between">
            <h3 class="font-semibold text-lg">情感趋势变化</h3>
            <select class="text-sm border border-neutral-300 rounded-lg px-3 py-1.5 focus:outline-none focus:ring-2 focus:ring-primary/50">
              <option>近7天</option>
              <option>近30天</option>
            </select>
          </div>
        </div>
        <div class="p-5">
          <div class="h-[220px]">
            <canvas id="emotionChart"></canvas>
          </div>
        </div>
      </div>
      
      <!-- 语音记录历史 -->
      <div class="card">
        <div class="p-5 border-b border-neutral-200">
          <div class="flex items-center justify-between">
            <h3 class="font-semibold text-lg">语音记录历史</h3>
            <button class="text-primary text-sm hover:underline">查看全部</button>
          </div>
        </div>
        <div class="divide-y divide-neutral-200">
          <!-- 记录1 -->
          <div class="p-4 hover:bg-neutral-50 transition-colors">
            <div class="flex items-start gap-3">
              <button class="w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center text-primary flex-shrink-0">
                <i class="fa fa-play"></i>
              </button>
              <div class="flex-1 min-w-0">
                <div class="flex items-center justify-between">
                  <h4 class="font-medium truncate">早晨心情记录</h4>
                  <span class="text-xs text-neutral-500">09:42</span>
                </div>
                <div class="flex flex-wrap gap-1 mt-1">
                  <span class="px-2 py-0.5 bg-danger/10 text-danger text-xs rounded-full">悲伤 85%</span>
                  <span class="px-2 py-0.5 bg-warning/10 text-warning text-xs rounded-full">焦虑 62%</span>
                </div>
                <p class="text-xs text-neutral-500 mt-2">时长: 2分35秒 · 今天</p>
              </div>
            </div>
          </div>
          
          <!-- 记录2 -->
          <div class="p-4 hover:bg-neutral-50 transition-colors">
            <div class="flex items-start gap-3">
              <button class="w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center text-primary flex-shrink-0">
                <i class="fa fa-play"></i>
              </button>
              <div class="flex-1 min-w-0">
                <div class="flex items-center justify-between">
                  <h4 class="font-medium truncate">晚间心情记录</h4>
                  <span class="text-xs text-neutral-500">21:15</span>
                </div>
                <div class="flex flex-wrap gap-1 mt-1">
                  <span class="px-2 py-0.5 bg-warning/10 text-warning text-xs rounded-full">焦虑 72%</span>
                  <span class="px-2 py-0.5 bg-neutral-200 text-neutral-700 text-xs rounded-full">平静 40%</span>
                </div>
                <p class="text-xs text-neutral-500 mt-2">时长: 1分58秒 · 昨天</p>
              </div>
            </div>
          </div>
          
          <!-- 记录3 -->
          <div class="p-4 hover:bg-neutral-50 transition-colors">
            <div class="flex items-start gap-3">
              <button class="w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center text-primary flex-shrink-0">
                <i class="fa fa-play"></i>
              </button>
              <div class="flex-1 min-w-0">
                <div class="flex items-center justify-between">
                  <h4 class="font-medium truncate">午后放松记录</h4>
                  <span class="text-xs text-neutral-500">15:30</span>
                </div>
                <div class="flex flex-wrap gap-1 mt-1">
                  <span class="px-2 py-0.5 bg-secondary/10 text-secondary text-xs rounded-full">平静 65%</span>
                  <span class="px-2 py-0.5 bg-primary/10 text-primary text-xs rounded-full">快乐 30%</span>
                </div>
                <p class="text-xs text-neutral-500 mt-2">时长: 3分02秒 · 前天</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  </main>
  
  <!-- 底部导航 -->
  <footer class="bg-white border-t border-neutral-200 py-2 sticky bottom-0 z-20">
    <div class="container mx-auto">
      <div class="flex items-center justify-around">
        <a href="#" class="nav-item active">
          <i class="fa fa-home text-xl"></i>
          <span class="text-xs mt-1">首页</span>
        </a>
        <a href="#" class="nav-item">
          <i class="fa fa-microphone text-xl"></i>
          <span class="text-xs mt-1">记录</span>
        </a>
        <a href="#" class="nav-item">
          <i class="fa fa-heart-o text-xl"></i>
          <span class="text-xs mt-1">疏导</span>
        </a>
        <a href="#" class="nav-item">
          <i class="fa fa-user-o text-xl"></i>
          <span class="text-xs mt-1">我的</span>
        </a>
      </div>
    </div>
  </footer>

  <!-- 录音模态框 (默认隐藏) -->
  <div id="recording-modal" class="fixed inset-0 bg-black/50 z-50 hidden items-center justify-center p-4">
    <div class="card w-full max-w-md">
      <div class="p-5 border-b border-neutral-200 text-center">
        <h3 class="font-semibold text-lg">记录你的心情</h3>
        <p class="text-sm text-neutral-500 mt-1">请描述一下今天的感受，持续1-3分钟</p>
      </div>
      <div class="p-6 flex flex-col items-center justify-center gap-6">
        <div class="w-24 h-24 rounded-full bg-danger flex items-center justify-center relative">
          <div class="absolute inset-0 rounded-full bg-danger/30 animate-ping"></div>
          <i class="fa fa-microphone text-white text-3xl relative z-10"></i>
        </div>
        <div>
          <span class="text-2xl font-mono font-medium" id="recording-time">00:00</span>
        </div>
        <div class="flex items-center gap-4 w-full">
          <button class="btn btn-outline flex-1">
            <i class="fa fa-pause"></i>
            <span>暂停</span>
          </button>
          <button class="btn btn-danger flex-1">
            <i class="fa fa-stop"></i>
            <span>结束</span>
          </button>
        </div>
      </div>
    </div>
  </div>

  <script>
    // 情感趋势图表
    const ctx = document.getElementById('emotionChart').getContext('2d');
    const emotionChart = new Chart(ctx, {
      type: 'line',
      data: {
        labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
        datasets: [
          {
            label: '正面情绪',
            data: [35, 40, 30, 25, 30, 20, 15],
            borderColor: '#10B981',
            backgroundColor: 'rgba(16, 185, 129, 0.1)',
            tension: 0.4,
            fill: true
          },
          {
            label: '负面情绪',
            data: [60, 55, 70, 75, 70, 75, 80],
            borderColor: '#EF4444',
            backgroundColor: 'rgba(239, 68, 68, 0.1)',
            tension: 0.4,
            fill: true
          }
        ]
      },
      options: {
        responsive: true,
        maintainAspectRatio: false,
        plugins: {
          legend: {
            position: 'top',
          }
        },
        scales: {
          y: {
            beginAtZero: true,
            max: 100,
            title: {
              display: true,
              text: '情感强度 (%)'
            }
          }
        }
      }
    });
    
    // 录音按钮功能
    document.querySelector('button:has(.fa-microphone)').addEventListener('click', function() {
      document.getElementById('recording-modal').classList.remove('hidden');
      document.getElementById('recording-modal').classList.add('flex');
      
      // 模拟录音计时
      let seconds = 0;
      const timerDisplay = document.getElementById('recording-time');
      const timer = setInterval(() => {
        seconds++;
        const minutes = Math.floor(seconds / 60);
        const secs = seconds % 60;
        timerDisplay.textContent = `${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
      }, 1000);
      
      // 结束录音
      document.querySelector('#recording-modal .btn-danger').addEventListener('click', function() {
        clearInterval(timer);
        document.getElementById('recording-modal').classList.add('hidden');
        document.getElementById('recording-modal').classList.remove('flex');
      });
    });
    
    // 播放按钮功能
    document.querySelectorAll('.fa-play').forEach(icon => {
      if (!icon.closest('#recording-modal')) {
        icon.parentElement.addEventListener('click', function() {
          const isPlaying = this.classList.contains('bg-primary');
          
          if (isPlaying) {
            this.classList.remove('bg-primary', 'text-white');
            this.classList.add('bg-primary/10', 'text-primary');
            icon.classList.remove('fa-pause');
            icon.classList.add('fa-play');
          } else {
            this.classList.remove('bg-primary/10', 'text-primary');
            this.classList.add('bg-primary', 'text-white');
            icon.classList.remove('fa-play');
            icon.classList.add('fa-pause');
          }
        });
      }
    });
  </script>
</body>
</html>
